﻿<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="<%=basePath%>">
<!-- jsp文件头和头部 -->
<%@ include file="../../system/main/main_top.jsp"%> 
</head> 
<body>
	<div class="container-fluid" id="main-container">
	<div id="breadcrumbs">
		<ul class="breadcrumb">
			<li><i class="icon-home"></i> <a>商户管理</a> <span class="divider">
					<i class="icon-angle-right"></i>
			</span></li>
			<li class="active">桌台管理</li>
		</ul>
		<!--.breadcrumb-->
	</div>
	<div id="page-content" class="clearfix">
	  <div class="row-fluid">
		<ul class="nav nav-tabs" id="myTab"> 
	      <li class="active" style="font-size: 14px;"><a href="#layer1">一层</a></li> 
	      <li style="font-size: 14px;"><a href="#layer2">二层</a></li> 
	    </ul> 
	    <div class="tab-content"> 
	      	<div class="tab-pane active" id="layer1">
	      		<input type="hidden" name="showLayer1" id="showLayer1" value="${pageData.showLayer1 }"/>
				<c:choose>
					<c:when test="${not empty tableList}">
						<c:forEach items="${tableList}" var="table" varStatus="vs">
							<div class="itemdiv memberdiv" style="width: 189px; height: 89px;">
	                            <div class="user">
	                            	<c:if test="${table.status == '0' }">
	                            		<div>
	                            			<span><i class="icon-group icon-2x green" style="margin-left: 10px;"></i></span>
	                            		</div>
	                            		<div>
	                            			<span class="label label-success arrowed-in" style="margin-top: 30px;">未预订</span>
	                            		</div>
	                            	</c:if>
									<c:if test="${table.status == '1' }">
										<span><i class="icon-group icon-2x red" style="margin-left: 10px;"></i></span>
										<span class="label label-important arrowed" style="margin-top: 30px;">已预订</span>
									</c:if>
	                            </div>
	                            
	                            <div class="body">
	                                <div class="name" style="margin-left: 10px;">编号：${table.tableno }</div>
	                                <div class="name" style="margin-left: 10px; font-size: 14px;">${table.tablename }</div>
	                                <div style="margin-top: 20px; margin-left: 10px;">
	                                    <a class='btn btn-mini btn-info' title="编辑" onclick="editTable('${table.tableid }', '1');"> 编辑</a> 
										<a class='btn btn-mini btn-warning' title="删除" onclick="delTable('${table.tableid }', '${table.tablename }', '1');"> 删除 </a>
	                                </div>
	                            </div>
	                        </div>
						</c:forEach>
					</c:when>
				</c:choose>
				<!--添加元素-->
	            <div class="itemdiv memberdiv" style="width: 189px; height: 89px;">
	                <div class="body">
	                    <div class="name" style="margin-top: 20px;">
	                        <span class="input-group-btn">
	                            <a class="btn btn-small btn-success icon-plus-sign" onclick="addTable('${pageData.organid }', '1');">&nbsp;&nbsp;添加桌台</a>
	                        </span>
	                    </div>
	                </div>
	            </div>
            </div>
            <div class="tab-pane" id="layer2">
            	<input type="hidden" name="showLayer2" id="showLayer2" value="${pageData.showLayer2 }"/>
				<c:choose>
					<c:when test="${not empty tableList2}">
						<c:forEach items="${tableList2}" var="table" varStatus="vs">
							<div class="itemdiv memberdiv" style="width: 189px; height: 89px;">
	                            <div class="user">
	                            	<c:if test="${table.status == '0' }">
	                            		<div>
	                            			<span><i class="icon-group icon-2x green" style="margin-left: 10px;"></i></span>
	                            		</div>
	                            		<div>
	                            			<span class="label label-success arrowed-in" style="margin-top: 30px;">未预订</span>
	                            		</div>
	                            	</c:if>
									<c:if test="${table.status == '1' }">
										<span><i class="icon-group icon-2x red" style="margin-left: 10px;"></i></span>
										<span class="label label-important arrowed" style="margin-top: 30px;">已预订</span>
									</c:if>
	                            </div>
	                            
	                            <div class="body">
	                                <div class="name" style="margin-left: 10px;">编号：${table.tableno }</div>
	                                <div class="name" style="margin-left: 10px; font-size: 14px;">${table.tablename }</div>
	                                <div style="margin-top: 20px; margin-left: 10px;">
	                                    <a class='btn btn-mini btn-info' title="编辑" onclick="editTable('${table.tableid }', '2');"> 编辑</a> 
										<a class='btn btn-mini btn-warning' title="删除" onclick="delTable('${table.tableid }', '${table.tablename }', '2');"> 删除 </a>
	                                </div>
	                            </div>
	                        </div>
						</c:forEach>
					</c:when>
				</c:choose>
				<!--添加元素-->
	            <div class="itemdiv memberdiv" style="width: 189px; height: 89px;">
	                <div class="body">
	                    <div class="name" style="margin-top: 20px;">
	                        <span class="input-group-btn">
	                            <a class="btn btn-small btn-success icon-plus-sign" onclick="addTable('${pageData.organid }', '2');">&nbsp;&nbsp;添加桌台</a>
	                        </span>
	                    </div>
	                </div>
	            </div>
            </div>
         </div>
        <!--添加元素-->
		<!-- PAGE CONTENT ENDS HERE -->
	  </div><!--/row-->
	  	<div class="name" style="margin-top: 20px;">
	      	<span class="input-group-btn">
		  		<a class="btn btn-small btn-success" onclick="updateTableStatus('${pageData.organid }');">&nbsp;&nbsp;一键还原桌台状态</a>
		  	</span>
		  	
		  	<span class="input-group-btn">
		 		<a class="btn btn-small btn-success" onclick="generateAllTablesTwoDimensionCode('${pageData.organid }');">&nbsp;&nbsp;一键生成桌台二维码</a>
		 	</span>
	  	</div>
	</div><!--/#page-content-->
	
	</div><!--/.fluid-container#main-container-->
<!-- 返回顶部  -->
<a href="#" id="btn-scroll-up" class="btn btn-small btn-inverse">
	<i class="icon-double-angle-up icon-only"></i>
</a>

<!-- 引入 -->
<script type="text/javascript">window.jQuery || document.write("<script src='static/js/jquery-1.9.1.min.js'>\x3C/script>");</script>
<script type="text/javascript" src="static/js/bootstrap.min.js"></script>
<script type="text/javascript" src="static/js/ace-elements.min.js"></script>
<script type="text/javascript" src="static/js/ace.min.js"></script>
<script type="text/javascript" src="static/js/chosen.jquery.min.js"></script><!-- 单选框 -->
<script type="text/javascript" src="static/js/bootstrap-datepicker.min.js"></script><!-- 日期框 -->
<script type="text/javascript" src="static/js/bootbox.min.js"></script><!-- 确认窗口 -->
<!-- 引入 -->

<script type="text/javascript">
$(top.hangge());

$(function() {
	//$('#myTab a:first').tab('show');//初始化显示哪个tab 
	var showLayer1 = $("#showLayer1").val();
	if(showLayer1 != null && showLayer1 == 'true'){
		$('#myTab a[href="#layer1"]').tab('show');
		//alert("LOGO上传成功！");
	}
	
	var showLayer2 = $("#showLayer2").val();
	if(showLayer2 != null && showLayer2 == 'true'){
		$('#myTab a[href="#layer2"]').tab('show');
		//alert("LOGO上传成功！");
	}
	
	$('#myTab a').click(function(e) {
		e.preventDefault();//阻止a链接的跳转行为 
		$(this).tab('show');//显示当前选中的链接及关联的content 
	});
});

//新增
function addTable(organid, layer){
	 //window.parent.jzts();
	top.jzts();
	var diag = new top.Dialog();
	diag.Drag=true;
	diag.Title ="新增";
	diag.URL = '<%=basePath%>/commercial/table/goAddTable.do' + '?organid=' + organid + '&layer=' + layer;
	diag.Width = 400;
	diag.Height = 580;
	diag.CancelEvent = function() { //关闭事件
		if (diag.innerFrame.contentWindow.document
				.getElementById('centerOfMainFrame').style.display == 'none') {
			top.jzts();
			//setTimeout("self.location.reload()", 100);
			window.location.href='<%=basePath%>/commercial/table/list.do?layer=' + layer;
		}
		diag.close();
	};
	diag.show();
}

//修改
function editTable(tableid, layer){
	 //window.parent.jzts();
	top.jzts();
	var diag = new top.Dialog();
	diag.Drag=true;
	diag.Title ="修改";
	diag.URL = '<%=basePath%>/commercial/table/goEditTable.do?tableid=' + tableid + '&layer=' + layer;
	diag.Width = 400;
	diag.Height = 580;
	diag.CancelEvent = function() { //关闭事件
		if (diag.innerFrame.contentWindow.document
				.getElementById('centerOfMainFrame').style.display == 'none') {
			top.jzts();
			//setTimeout("self.location.reload()", 100);
			window.location.href='<%=basePath%>/commercial/table/list.do?layer=' + layer;
		}
		diag.close();
	};
	diag.show();
}

//删除
function delTable(tableid, msg, layer){
	bootbox.confirm("确定要删除["+msg+"]吗?", function(result) {
		if(result) {
			var url = "<%=basePath%>/commercial/table/deleteTable.do?tableid=" + tableid  + "&layer=" + layer + "&tm="+ new Date().getTime();
			$.get(url,function(data){
				//if(data=="success"){
					top.jzts();
					setTimeout("self.location.reload()", 100);
				//}
			});
		}
	});
}

//删除
function updateTableStatus(organid){
	bootbox.confirm("确定还原所有桌台的状态吗?", function(result) {
		if(result) {
			var url = "<%=basePath%>/commercial/table/updateTableStatus.do?organid=" + organid + "&tm="+ new Date().getTime();
			$.get(url,function(data){
				//if(data=="success"){
					top.jzts();
					setTimeout("self.location.reload()", 100);
				//}
			});
		}
	});
}

function generateAllTablesTwoDimensionCode(organid){
	bootbox.confirm("确定生成所有桌台的二维码吗?", function(result) {
		if(result) {
			var url = "<%=basePath%>/commercial/table/generateAllTablesTwoDimensionCode.do?organid=" + organid + "&tm="+ new Date().getTime();
			$.get(url,function(data){
				//alert(data);
				//if(data=="success"){
					//top.jzts();
					bootbox.alert("操作成功！");
					//alert("生成成功！");
					//setTimeout("self.location.reload()", 100);
				//}
			});
		}
	});
}
</script>
</body>
</html>

